package com.example.controller;

import com.example.OllamaChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping
public class ChatController {

    OllamaChatService ollamaChatService;

    @Autowired
    public void setChatService(OllamaChatService ollamaChatService) {
        this.ollamaChatService = ollamaChatService;
    }

    @GetMapping("/chat")
    public Mono<String> chat(@RequestParam(name = "message") String message) {
        String chat = ollamaChatService.chat(message);
        Mono<String> mono = Mono.just(chat);
        return mono;
    }
}
